package com.example.exam;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseExpandableListAdapter;
import android.widget.TextView;

import java.util.ArrayList;
import java.util.List;

public class ExpandAdapter extends BaseExpandableListAdapter {
    List<String> list = new ArrayList<>();
    List<List<String>> lists = new ArrayList<>();
    Context context;
    private TextView text;

    public ExpandAdapter(Context context) {
        this.context = context;
        list.add("233");
        list.add("233");
        list.add("233");
        list.add("233");
        list.add("233");
        lists.add(list);
        lists.add(list);
        lists.add(list);
        lists.add(list);
        lists.add(list);
    }

    @Override
    public int getGroupCount() {
        return list.size();
    }

    @Override
    public int getChildrenCount(int i) {
        return lists.get(i).size();
    }

    @Override
    public Object getGroup(int i) {
        return list.get(i);
    }

    @Override
    public Object getChild(int i, int i1) {
        return lists.get(i).get(i1);
    }

    @Override
    public long getGroupId(int i) {
        return i;
    }

    @Override
    public long getChildId(int i, int i1) {
        return i1;
    }

    @Override
    public boolean hasStableIds() {
        return false;
    }

    @Override
    public View getGroupView(int i, boolean b, View view, ViewGroup viewGroup) {
        view = LayoutInflater.from(context).inflate(R.layout.layout, viewGroup, false);
        ViewHolder1 viewHolder1 = new ViewHolder1(view);
        viewHolder1.text.setText(list.get(i));
        return view;
    }

    @Override
    public View getChildView(int i, int i1, boolean b, View view, ViewGroup viewGroup) {
        view = LayoutInflater.from(context).inflate(R.layout.layout, viewGroup, false);
        ViewHolder1 viewHolder1 = new ViewHolder1(view);
        viewHolder1.text.setText(lists.get(i).get(i1));
        return view;
    }

    @Override
    public boolean isChildSelectable(int i, int i1) {
        return false;
    }


    public
    class ViewHolder1 {
        public View rootView;
        public TextView text;

        public ViewHolder1(View rootView) {
            this.rootView = rootView;
            this.text = (TextView) rootView.findViewById(R.id.text);
        }

    }

}
